//
// Created by Jisam on 2024/8/11 19:00.
// solve a
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> a(26,0);
    string s;
    cin >> s;
    int m = 0,sum = 0;
    for(int i = 0 ; i < s.length() ; i ++)
    {
        a[s[i] - 'a'] ++;
        m = max(m,a[s[i] - 'a']);
    }
    cout << s.length() - m;
    return 0;
}